import Cocoa
import FlutterMacOS

public class FlutterWidgetsPcPlugin: NSObject, FlutterPlugin {
    public static func register(with registrar: FlutterPluginRegistrar) {
        let channel = FlutterMethodChannel(name: "flutter_widgets_pc", binaryMessenger: registrar.messenger)
        let instance = FlutterWidgetsPcPlugin()
        registrar.addMethodCallDelegate(instance, channel: channel)
    }

    public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
        switch call.method {
        case "getPlatformVersion":
            result("macOS " + ProcessInfo.processInfo.operatingSystemVersionString)
        case "bringToFront":
//       NSApplication.shared.activate(ignoringOtherApps: true)
            let app = NSRunningApplication.current
            app.activate(options: [.activateAllWindows, .activateIgnoringOtherApps])
            result(nil)
        case "enableImmersive":
            NSApp.presentationOptions = [
                     .hideDock,
                     .hideMenuBar,
                     .disableProcessSwitching
                   ]
            result(nil)
        case "restorePresentation":
            NSApp.presentationOptions = []
            result(nil)
        default:
            result(FlutterMethodNotImplemented)
        }
    }
}
